#ifndef _conf_h
#define _conf_h

#define CNT_CONF			CNT_SEC * 2
#define CONF_BITS_SIZE		7

typedef struct _conf_t {
	uint32_t f;
	uint32_t aft;
	uint32_t aft_repeat;
	uint32_t lcd;
	uint32_t vibro;
	uint32_t vibro_detect;
	uint32_t vibro_aft;
	uint32_t lcd_power;
	uint32_t vibro_power;
	uint8_t crc8;
} conf_t;

typedef struct _conf_item_adj_t {
	uint32_t div;
	uint32_t step;
	uint32_t max;
} conf_item_adj_t;

enum conf_bits_t {
	CB_BEEP_BEEP,
	CB_BEEP_LCD,
	CB_BEEP_VIBRO,
	CB_AFT_BEEP,
	CB_AFT_LCD,
	CB_AFT_VIBRO,
	CB_LCD_DIMM
};

enum conf_action_t {
	CA_NONE,
	CA_NEXT,
	CA_PREV,
	CA_INC,
	CA_DEC,
	CA_SAVE_EXIT,
	CA_DISCARD_EXIT,
	CA_SHOW
};

void conf_loop(void);
static conf_action_t conf_action(void);
static bool conf_action_confirm(uint8_t i);
static bool push_conf_item(conf_action_t action);
void read_conf(void);
static void write_conf(void);
static uint8_t crc8(uint8_t *buf, uint8_t size);

#endif
